﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Furion.Logging;
using Mapster;

namespace TimeJob.Core
{
    public class DatabaseLoggingWriter : IDatabaseLoggingWriter
    {
        // 支持构造函数注入
        public DatabaseLoggingWriter()
        {
        }

        public  Task WriteAsync(LogMessage logMsg, bool flush)   // Furion 4.9.1.58 之前为 public void Write(LogMessage logMsg, bool flush)
        {
            // 这里写你任何插入数据库的操作，无需 try catch
           var l =  logMsg.Adapt<LogTable>();
            return DbContext.Instance.Insertable<LogTable>(l).ExecuteCommandAsync();
        }
    }
}
